package com.thinkfit.jy.adapter;

import android.content.Context;
import android.text.TextUtils;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.common.lib.bean.SportRecordBean;
import com.common.lib.utils.BaseUtils;
import com.thinkfit.jy.R;

import org.jetbrains.annotations.NotNull;

public class SportRecordAdapter extends BaseQuickAdapter<SportRecordBean, BaseViewHolder> {

    private Context mContext;

    public SportRecordAdapter(Context context) {
        super(R.layout.item_sport_record);
        mContext = context;
    }


    @Override
    protected void convert(@NotNull BaseViewHolder helper, SportRecordBean bean) {
        String text = bean.getTitle();
        if (!TextUtils.isEmpty(bean.getDrillname())) {
            text += "-" + bean.getDrillname();
        }
        int time = (int) (bean.getRecord().getEndtime() - bean.getRecord().getStarttime());
        int hour = time / 3600;
        int minute = time / 60 % 60;
        int second = time % 60;
        helper.setText(R.id.tvTitle, text)
                .setText(R.id.tvTime, BaseUtils.StaticParams.getNewText(hour) + ":"
                        + BaseUtils.StaticParams.getNewText(minute) + ":"
                        + BaseUtils.StaticParams.getNewText(second))
                .setText(R.id.tvDate, bean.getDatetime())
                .setGone(R.id.line, getItemPosition(bean) == getItemCount() - 1);
    }


}
